<template>
    <div>
        <div class=page-title-section style="background-image:url(images/parallax-5.jpg)">
            <div class=container>
                <div class="center-holder page-title">
                    <h1>公司资讯</h1>
                    <p style="color: white;">
                        汇集了公司内部、外部、合作伙伴最新信息的简讯
                    </p>
                </div>
            </div>
        </div>
        <div class="container">

            <div class="blog-list" v-for="(item,index) in dataSource" :key="index">
                <div class="row">
                    <div class="col-xs-12 col-sm-12 col-md-8">
                        <img alt=blog-image :src="item.img">
                    </div>
                    <div class="col-xs-12 col-sm-12 col-md-4">
                        <div class="blog-list-text">
                            <h6>{{new Date(item._createTime).Format('yyyy年MM月dd日')}}</h6>
                            <h3 @click="toInformationDetails(item)"><a>{{item.title}}</a></h3>
                            <p>{{item.content}}</p>
                            <div class=blog-list-admin>
                                {{item.author}}
                                <span>阅读量 {{item.readingNumber || 0}}</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
</template>

<script>
    import {editInformation, getInformationList} from "../../api/base";

    export default {
        name: "Information",
        data() {
            return {
                dataSource: []
            }
        },
        mounted() {
            this.getDataSource();
        },
        methods: {
            getDataSource: async function () {
                this.dataSource = await getInformationList();
            },
            // 查看资讯详情
            toInformationDetails: async function (item) {
                let id = item['_id'];
                if(id){
                    await editInformation({id});
                }
                this.$router.push({
                    path: '/information_details',
                    query: {
                        item : encodeURIComponent(JSON.stringify(item))
                    }
                })
            }
        }
    }
</script>

<style scoped>

</style>